#include "MultiTimer.h"


#define LED *(volatile int*)0x80000000            // led port
#define TIK *(volatile unsigned int*)0x80001000   // ms计时器

#define FLOAT_OUT  *(volatile unsigned int*)0x80000200  



unsigned int PlatformTik(){
    return TIK;
}

void delay_ms(int ms){
	unsigned int b = TIK;
	while(TIK <= ms + b) ;
    // for(int i=0;i<20000;i++) ;
	return ;
}

MultiTimer timer1 , timer2;

void timer1_cb(MultiTimer* timer, void* userData) {
    LED =~LED ;
    MultiTimerStart(timer, 0, timer1_cb, userData);
}

void timer2_cb(MultiTimer* timer, void* userData) {
    // FLOAT_OUT = TIK ;
    MultiTimerStart(timer, 10, timer2_cb, userData);
}

void main()
{
    MultiTimerInstall(PlatformTik) ;
    MultiTimerStart(&timer1, 0, timer1_cb, nullptr);
    // MultiTimerStart(&timer2, 0, timer2_cb, nullptr);
	LED = 1;
	while(1){
		MultiTimerYield();
        // LED = ~LED ;
        // delay_ms(500);
	}
	return ;
}


